#!/bin/bash

OK=false
echo -n "Test 1 - LOAD ..... "

../../spblaze -t kcpsm3 -o test1 -x test1.hex > output1.txt 2> error1.txt < commands.txt

# REGISTERS
RESULT=$(xml_grep --text_only '//regbank' test1_state.xml)
RESULT=${RESULT:0:32}
EXPECTED=$(xml_grep --text_only '//regbank' test1_state_expected.xml)
EXPECTED=${EXPECTED:0:32}

# PC
RESULT_PC=$(xml_grep --text_only '//pc' ./test1_state.xml)
EXPECTED_PC=$(xml_grep --text_only '//pc' ./test1_state_expected.xml)

if [ $RESULT = $EXPECTED -a $RESULT_PC = $EXPECTED_PC ]
then        
  OK=true
  echo "OK"
else
  echo "FAIL"
fi

if $OK
then
  exit 0
else
  exit 1
fi

